The Making of a Blog

25 April 2011

How much code does a blog take?

1.8KB. It might be simple but this includes its PHP, HTML and CSS.

My minimalistic blog is quite simple. It uses PHP's built-in parse-ini-file() to parse an .ini file (which stores all blog entries) into a hash. The keys are the sections of the .ini file and the values are themselves hashes that contain the sections' value-pairs.

All that is left is a for-loop that iterates over the top-level hash to generate 3 rows of a HTML table at a time. The upper row contains the heading and the date, the middle one has the body text while the lower is for the comments link.


$contents = parse_ini_file('entries.ini', true);

foreach ($contents as $header => $data) {

	echo "<tr style=\"background: $data[color];\">";

	...

}


Comments for The Making of a Blog

Rouslan on April 26, 2011, 1:15:49 am EDT

Clicking on the PHP link might seem to show a broken web page. It is not! This is the PHP source file.


Post a new comment

Name: Comment:
Email(hidden):
2 + 0:
9 characters word:
visits.